package com.zhijiaoyun.controller;

import com.zhijiaoyun.common.DsConstant;
import com.zhijiaoyun.controller.base.BaseController;
import com.zhijiaoyun.model.FeedBack;
import com.zhijiaoyun.model.dto.PageList;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author shisfish
 * @date 2018/1/18
 */
@Controller
@RequestMapping(value = "/message", produces = "application/json; charset=utf-8")
public class MessageController extends BaseController {

    /**
     * 反馈信息列表
     *
     * @param pageIndex
     * @param pageSize
     * @param content
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/feedbacks", method = RequestMethod.GET)
    public Map<String, Object> feedbacks(int pageIndex, int pageSize, String content) {
        if (pageIndex <= 0) {
            pageIndex = 1;
        }
        if (pageSize <= 0) {
            pageSize = DsConstant.PAGESIZE_DEFAULT;
        }
        PageList<FeedBack> feedBacks = feedBackServie.page(pageIndex, pageSize, content);
        Map<String, Object> map = new HashMap<>();
        map.put(LIST, feedBacks.getList());
        map.put(PAGE, feedBacks.getPageData());
        return responseSuccessMap(map);
    }

}
